package patrol.mobile.com.mobilepatrol.activity;

import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.View;
import android.widget.EditText;

import butterknife.BindView;
import patrol.mobile.com.mobilepatrol.R;

/**
 * Created by apple on 18/1/16.
 */

public class TestActivity2 extends BaseActivity {
    @BindView(R.id.et)
    EditText et;
    @Override
    protected int attachLayoutRes() {
        return R.layout.activity_test2;
    }

    @Override
    public void setListener() {
        et.addTextChangedListener(new TextWatcher() {

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                // 输入的内容变化的监听
                Log.e("输入过程中执行该方法", "文字变化 "+s.toString());
            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count,
                                          int after) {
                // 输入前的监听
                Log.e("输入前确认执行该方法", "开始输入"+s.toString());

            }

            @Override
            public void afterTextChanged(Editable s) {
                if (!et.isFocused()){
                    Log.e("输入结束执行该方法", "输入结束"+s.toString());
                }
            }
        });
        et.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                if (hasFocus){

                }else{
                    Log.e("输入结束执行该方法", "输入结束"+et.getText().toString());
                }
            }
        });
    }

    public void initView() {

    }
}